package svgedit.gui.actions;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.AbstractAction;
import svgedit.gui.Frame;
import svgedit.gui.View;
import svgedit.svg.SVGElement;

/**
 * Action used to delete an SVGElement
 * 
 * @author SARJ
 * 
 */
public class DeleteAction extends AbstractAction implements ActionListener
{
	private static final long serialVersionUID = -3433876954352062278L;

	/**
	 * Construct a DeleteAction
	 */
	public DeleteAction()
	{
		super("Delete");
	}

	@Override
	public void actionPerformed(ActionEvent arg0)
	{
		View view = Frame.getFrame().getView();
		for (SVGElement element : view.getSelected())
		{
			System.out.println("Deleting " + element.toString());
			element.destroy();
		}
		Frame.getFrame().enableDeleteMenuItem(false);
		view.repaint();

	}

}
